import { Card } from "@nutui/nutui-react-taro";
import { View } from "@tarojs/components";
import { checkAuth } from "@/lib/auth";
import Taro from "@tarojs/taro";

const Item = ({ data }) => {
  /**
   * 点击事件
   * @param {}
   * @return
   */
  const handleClick = () => {
    /**
     * 先判断是否登录，如果未登录跳转登录，登录过则执行下一步
     */
    checkAuth(
      () => {
        Taro.showToast({
          title: "点击成功",
        });
      },
      {
        isSwitchTab: true,
        backurl: "/pages/list/index",
      }
    );
  };
  return (
    <View className="m-[24rpx] last:mb-[0]" onClick={handleClick}>
      <Card
        src={data.src}
        title={data.title}
        price={data.price}
        vipPrice={data.vipPrice}
        shopDescription={data.shopDescription}
        delivery={data.delivery}
        shopName={data.shopName}
      />
    </View>
  );
};
export default Item;
